<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    {{template "title"}}
    {{template "commonCss"}}
    {{template "commonJs"}}
    {{template "headerAndFooter"}}
</head>
<body>
{{template "header" .}}
<div class="container">
    <div class="left-list-container">
        <ul class="list-group">
            {{range .articleList}}
                <li class="list-group-item">
                    <h3>
                        <a href="/article/articleDetail/?articleId={{.Id}}">{{.Title}}</a>
                    </h3>
                    <p>
                        {{.About}}
                    </p>
                    <p>
                        <span class="publish-time">
                            <span class="glyphicon glyphicon-calendar"></span>
                            <span>{{.CreateTime.Format "2006-01-02 15:04:05"}}</span>
                        </span>
                    </p>
                </li>
            {{end}}
        </ul>

        <nav aria-label="Page navigation">
            <ul class="pager">
                {{if .pageModel.HasPre}}
                <li><a href="{{.pageModel.PreLink}}">上一页</a></li>
                {{end}}
                {{if .pageModel.HasNext}}
                <li><a href="{{.pageModel.NextLink}}">下一页</a></li>
                {{end}}
            </ul>
        </nav>
    </div>
    <div class="right-list-container">
        <img src="/static/image/titoni.jpg" alt="">
    </div>
</div>


{{template "footer"}}
<script>

    // 获取url地址方法
    function getQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return unescape(r[2]);
        return null;
    }

    // 上一页
    $("#previousPage").click(function () {
        console.log(getQueryString("pageNumber"));
        if (!getQueryString("pageNumber")) {
            $(window).attr('location', '/index?pageNumber=1');
        }
        if (getQueryString("pageNumber") > 1) {
            $(window).attr('location', '/index?pageNumber=' + (Number(getQueryString("pageNumber")) - 1));
        }
    });

    // 下一页
    $("#nextPage").click(function () {
        console.log(getQueryString("pageNumber"));
        if (!getQueryString("pageNumber")) {
            $(window).attr('location', '/index?pageNumber=1');
        } else {
            $(window).attr('location', '/index?pageNumber=' + (Number(getQueryString("pageNumber")) + 1));
        }
    });


</script>
</body>
</html>